<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="Hexo最常用的几个命令 Hexo 约有二十个命令，但普通用户经常使用的大概只有下列几个:  hexo s1hexo s 启动本地服务器，用于预览主题。默认地址： http:&#x2F;&#x2F;localhost:4000&#x2F;  hexo s 是 hexo server 的缩写，命令效果一致； 预览的同时可以修改文章内容或主题代码，保存后刷新页面即可； 对 Hexo 根目录 _config.yml 的修改，需要重启">
<meta property="og:type" content="article">
<meta property="og:title" content="Hexo最常用的几个命令">
<meta property="og:url" content="http://example.com/2021/01/10/Hexo%E6%9C%80%E5%B8%B8%E7%94%A8%E7%9A%84%E5%87%A0%E4%B8%AA%E5%91%BD%E4%BB%A4/index.html">
<meta property="og:site_name" content="解救Z先生">
<meta property="og:description" content="Hexo最常用的几个命令 Hexo 约有二十个命令，但普通用户经常使用的大概只有下列几个:  hexo s1hexo s 启动本地服务器，用于预览主题。默认地址： http:&#x2F;&#x2F;localhost:4000&#x2F;  hexo s 是 hexo server 的缩写，命令效果一致； 预览的同时可以修改文章内容或主题代码，保存后刷新页面即可； 对 Hexo 根目录 _config.yml 的修改，需要重启">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-01-10T02:10:03.000Z">
<meta property="article:modified_time" content="2021-01-13T13:59:11.977Z">
<meta property="article:author" content="greentree">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/2021/01/10/Hexo%E6%9C%80%E5%B8%B8%E7%94%A8%E7%9A%84%E5%87%A0%E4%B8%AA%E5%91%BD%E4%BB%A4/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Hexo最常用的几个命令 | 解救Z先生</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">解救Z先生</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/aboutme/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/01/10/Hexo%E6%9C%80%E5%B8%B8%E7%94%A8%E7%9A%84%E5%87%A0%E4%B8%AA%E5%91%BD%E4%BB%A4/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="greentree">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="解救Z先生">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Hexo最常用的几个命令
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-10 10:10:03" itemprop="dateCreated datePublished" datetime="2021-01-10T10:10:03+08:00">2021-01-10</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-13 21:59:11" itemprop="dateModified" datetime="2021-01-13T21:59:11+08:00">2021-01-13</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="Hexo最常用的几个命令"><a href="#Hexo最常用的几个命令" class="headerlink" title="Hexo最常用的几个命令"></a>Hexo最常用的几个命令</h1><blockquote>
<p>Hexo 约有二十个命令，但普通用户经常使用的大概只有下列几个:</p>
</blockquote>
<h2 id="hexo-s"><a href="#hexo-s" class="headerlink" title="hexo s"></a>hexo s</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo s</span><br></pre></td></tr></table></figure>
<p>启动本地服务器，用于预览主题。默认地址： <a target="_blank" rel="noopener" href="https://link.jianshu.com/?t=http://localhost:4000/">http://localhost:4000/</a></p>
<ul>
<li><code>hexo s</code> 是 <code>hexo server</code> 的缩写，命令效果一致；</li>
<li>预览的同时可以修改文章内容或主题代码，保存后刷新页面即可；</li>
<li>对 Hexo 根目录 <code>_config.yml</code> 的修改，需要重启本地服务器后才能预览效果。</li>
</ul>
<h2 id="hexo-n"><a href="#hexo-n" class="headerlink" title="hexo n"></a>hexo n</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo n <span class="string">&quot;学习笔记  六&quot;</span></span><br></pre></td></tr></table></figure>
<p>新建一篇标题为 <code>学习笔记 六</code> 的文章，因为标题里有空格，所以加上了引号。</p>
<ul>
<li>文章标题可以在对应 md 文件里改，新建时标题可以写的简单些；</li>
<li><code>hexo n</code> 是 <code>hexo new</code> 的缩写，命令效果一致。</li>
</ul>
<h3 id="文章可以拥有如下属性："><a href="#文章可以拥有如下属性：" class="headerlink" title="文章可以拥有如下属性："></a>文章可以拥有如下属性：</h3><table>
<thead>
<tr>
<th align="center">-</th>
<th>Setting</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody><tr>
<td align="center">1</td>
<td>layout</td>
<td>Layout</td>
<td>post或page</td>
</tr>
<tr>
<td align="center">2</td>
<td>title</td>
<td>文章的标题</td>
<td></td>
</tr>
<tr>
<td align="center">3</td>
<td>date</td>
<td>创建日期</td>
<td>文件的创建日期</td>
</tr>
<tr>
<td align="center">4</td>
<td>updated</td>
<td>修改日期</td>
<td>文件的修改日期</td>
</tr>
<tr>
<td align="center">5</td>
<td>comments</td>
<td>是否开启评论</td>
<td>true</td>
</tr>
<tr>
<td align="center">6</td>
<td>tags</td>
<td>标签</td>
<td></td>
</tr>
<tr>
<td align="center">7</td>
<td>categories</td>
<td>分类</td>
<td></td>
</tr>
<tr>
<td align="center">8</td>
<td>permalink</td>
<td>url中的名字</td>
<td>文件名</td>
</tr>
</tbody></table>
<p>动态博客中通过发布文章页面设置的各种属性，在hexo里要这样设置。</p>
<h2 id="hexo-d"><a href="#hexo-d" class="headerlink" title="hexo d"></a>hexo d</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo d</span><br></pre></td></tr></table></figure>
<p>自动生成网站静态文件，并部署到设定的仓库。</p>
<ul>
<li><code>hexo d</code> 是 <code>hexo deploy</code> 的缩写，命令效果一致。</li>
</ul>
<h2 id="hexo-clean"><a href="#hexo-clean" class="headerlink" title="hexo clean"></a>hexo clean</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo clean</span><br></pre></td></tr></table></figure>
<p>清除缓存文件 <code>db.json</code> 和已生成的静态文件 <code>public</code>。</p>
<ul>
<li>网站显示异常时可以执行这条命令试试。</li>
</ul>
<h2 id="hexo-g"><a href="#hexo-g" class="headerlink" title="hexo g"></a>hexo g</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo g</span><br></pre></td></tr></table></figure>
<p>生成网站静态文件到默认设置的 <code>public</code> 文件夹。</p>
<ul>
<li>便于查看网站生成的静态文件或者手动部署网站；</li>
<li>如果使用自动部署，不需要先执行该命令；</li>
<li><code>hexo g</code> 是 <code>hexo generate</code> 的缩写，命令效果一致。</li>
</ul>
<h2 id="hexo-n-page"><a href="#hexo-n-page" class="headerlink" title="hexo n page"></a>hexo n page</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo n page aboutme</span><br></pre></td></tr></table></figure>
<p>新建一个标题为 <code>aboutme</code> 的页面，默认链接地址为 <code>主页地址/aboutme/</code></p>
<ul>
<li>标题可以为中文，但一般习惯用英文；</li>
<li>页面标题和文章一样可以随意修改；</li>
<li>页面不会出现在首页文章列表和归档中，也不支持设置分类和标签。</li>
</ul>
<h2 id="常用组合"><a href="#常用组合" class="headerlink" title="常用组合"></a>常用组合</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hexo clean &amp;&amp; hexo s</span><br><span class="line">hexo clean &amp;&amp; hexo d</span><br></pre></td></tr></table></figure>
<p>可以用输入法等软件为这些命令设置快捷键，方便调用。</p>
<h2 id="草稿"><a href="#草稿" class="headerlink" title="草稿"></a>草稿</h2><p>草稿相当于很多博客都有的“私密文章”功能。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo <span class="keyword">new</span> draft <span class="string">&quot;new draft&quot;</span></span><br></pre></td></tr></table></figure>
<p>会在source/_drafts目录下生成一个new-draft.md文件。但是这个文件不被显示在页面上，链接也访问不到。也就是说如果你想把某一篇文章移除显示，又不舍得删除，可以把它移动到_drafts目录之中。</p>
<ul>
<li>如果你希望强行预览草稿，更改配置文件：</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">render_drafts: <span class="literal">true</span></span><br></pre></td></tr></table></figure>
<ul>
<li>或者，如下方式启动server：</li>
</ul>
<figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$ </span>hexo server --drafts</span><br></pre></td></tr></table></figure>
<ul>
<li>下面这条命令可以把草稿变成文章，或者页面：</li>
</ul>
<figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$ </span>hexo publish [layout] &lt;filename&gt;</span><br></pre></td></tr></table></figure>
<h2 id="相关说明"><a href="#相关说明" class="headerlink" title="相关说明"></a>相关说明</h2><ul>
<li>以上命令使用基于 Hexo 3.1.1 版本；</li>
<li>需要删掉用命令新建的文章或页面时，只需要进入 Hexo 根目录下的 <code>source</code> 文件夹，删除对应文件或文件夹即可；</li>
<li>更多命令用法请查询 <a target="_blank" rel="noopener" href="https://link.jianshu.com/?t=https://hexo.io/zh-cn/docs/commands.html">官方文档</a>。</li>
</ul>
<p>作者：指尖的跳跃<br>链接：<a target="_blank" rel="noopener" href="https://www.jianshu.com/p/a2d298e26dcd">https://www.jianshu.com/p/a2d298e26dcd</a><br>来源：简书<br>著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。</p>

    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/01/09/cmake%E4%B8%8Ecppcheck%E9%9B%86%E6%88%90/" rel="prev" title="cmake与cppcheck集成">
      <i class="fa fa-chevron-left"></i> cmake与cppcheck集成
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/01/10/CSDN%E6%B2%A1%E6%9C%89%E7%A7%AF%E5%88%86%E6%80%8E%E4%B9%88%E5%85%8D%E8%B4%B9%E4%B8%8B%E8%BD%BD/" rel="next" title="CSDN没有积分怎么免费下载">
      CSDN没有积分怎么免费下载 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Hexo%E6%9C%80%E5%B8%B8%E7%94%A8%E7%9A%84%E5%87%A0%E4%B8%AA%E5%91%BD%E4%BB%A4"><span class="nav-number">1.</span> <span class="nav-text">Hexo最常用的几个命令</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#hexo-s"><span class="nav-number">1.1.</span> <span class="nav-text">hexo s</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#hexo-n"><span class="nav-number">1.2.</span> <span class="nav-text">hexo n</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%96%87%E7%AB%A0%E5%8F%AF%E4%BB%A5%E6%8B%A5%E6%9C%89%E5%A6%82%E4%B8%8B%E5%B1%9E%E6%80%A7%EF%BC%9A"><span class="nav-number">1.2.1.</span> <span class="nav-text">文章可以拥有如下属性：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#hexo-d"><span class="nav-number">1.3.</span> <span class="nav-text">hexo d</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#hexo-clean"><span class="nav-number">1.4.</span> <span class="nav-text">hexo clean</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#hexo-g"><span class="nav-number">1.5.</span> <span class="nav-text">hexo g</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#hexo-n-page"><span class="nav-number">1.6.</span> <span class="nav-text">hexo n page</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B8%B8%E7%94%A8%E7%BB%84%E5%90%88"><span class="nav-number">1.7.</span> <span class="nav-text">常用组合</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%8D%89%E7%A8%BF"><span class="nav-number">1.8.</span> <span class="nav-text">草稿</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%9B%B8%E5%85%B3%E8%AF%B4%E6%98%8E"><span class="nav-number">1.9.</span> <span class="nav-text">相关说明</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">greentree</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">13</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">greentree</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
